#pragma once

class CLogFileWriter
{
public:
	CLogFileWriter(void);
	~CLogFileWriter(void);

	static void Print(int level, char* fileName, int lineNumber, char* functionName, char* formatString, ...);

	static void	Lock();
	static void	UnLock();
};

#define _FATAL_		0
#define _ERROR_		1
#define _WARNING_	2
#define _INFO_		3
#define _DEBUG_		4
#define _FINE_		5
#define _FINEST_	6

#ifdef VALIDATE_FROMAT_SPECIFIERS
#define __VALIDATE_FROMAT_SPECIFIERS(...) \
	do { \
	char ___tempLocation[1024]; \
	snprintf(___tempLocation,1023,__VA_ARGS__); \
	}while (0)
#else
#define __VALIDATE_FROMAT_SPECIFIERS(...)
#endif /* VALIDATE_FROMAT_SPECIFIERS */

#define __LOG(level,...) do{__VALIDATE_FROMAT_SPECIFIERS(__VA_ARGS__);CLogFileWriter::Print(level, __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__);}while(0)
#define __FATAL(...) do{__VALIDATE_FROMAT_SPECIFIERS(__VA_ARGS__);CLogFileWriter::Print(_FATAL_, __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__);}while(0)

#define __WARN(...) do{__VALIDATE_FROMAT_SPECIFIERS(__VA_ARGS__);CLogFileWriter::Print(_WARNING_, __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__);}while(0)
#define __INFO(...) do{__VALIDATE_FROMAT_SPECIFIERS(__VA_ARGS__);CLogFileWriter::Print(_INFO_, __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__);}while(0)
#define __DEBUG(...) do{__VALIDATE_FROMAT_SPECIFIERS(__VA_ARGS__);CLogFileWriter::Print(_DEBUG_, __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__);}while(0)
#define __FINE(...) do{__VALIDATE_FROMAT_SPECIFIERS(__VA_ARGS__);CLogFileWriter::Print(_FINE_, __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__);}while(0)
#define __FINEST(...) do{__VALIDATE_FROMAT_SPECIFIERS(__VA_ARGS__);CLogFileWriter::Print(_FINEST_, __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__);}while(0)
#define __ASSERT(...) do{__VALIDATE_FROMAT_SPECIFIERS(__VA_ARGS__);CLogFileWriter::Print(_FATAL_, __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__);assert(false);abort();}while(0)

